package com.esun.util.update;

import java.util.Hashtable;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class SAXHandler extends DefaultHandler {

	// private String version ;
	// private String date;
	// private String add;

	private Hashtable<String, String> map = new Hashtable<String, String>();

	@Override
	public void startDocument() throws SAXException {
		super.startDocument();

	}

	@Override
	public void endDocument() throws SAXException {

		super.endDocument();
	}

	@Override
	public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {

		if (localName.equals("aelk")) {

			for (int i = 0; i < attributes.getLength(); i++) {
				map.put(attributes.getLocalName(i), attributes.getValue(i));
			}
		}
	}

	@Override
	public void endElement(String uri, String localName, String qName) throws SAXException {
	}

	@Override
	public void characters(char[] ch, int start, int length) throws SAXException {
		String value = new String(ch, start, length);
		value = value.trim();
		if (value.length() == 0)
			return;

	}

	public Hashtable<String, String> getInfo() {
		return map;
	}

}
